package School;
abstract class Shape{
    public static final double PI=3.14159;
    abstract double Area();
    abstract double Perimeter();
}
class Circle extends Shape{
    double r=0;
    public Circle(double r){
        this.r=r;
    }
    double Area(){
        return PI*r*r;
    }
    double Perimeter(){
        return 2*PI*r;
    }
}
class Square extends Shape{
    double x=0;
    public Square(double x){
        this.x=x;
    }
    double Area(){
        return x*x;
    }
    double Perimeter(){
        return 4*x;
    }
}
public class TestDemo1 {
    public static void main(String[] args){
        Circle circle=new Circle(3.1);
        System.out.println("圆的面积为："+circle.Area());
        System.out.println("圆的周长为："+circle.Perimeter());
        Square square=new Square(4);
        System.out.println("正方形的面积为："+square.Area());
        System.out.println("正方形的周长为："+square.Perimeter());

//        Shape shape=new Circle(3.1);
//        System.out.println("圆的面积为："+shape.Area());
//        System.out.println("圆的周长为："+shape.Perimeter());
//
//        Shape shape1=new Square(4);
//        System.out.println("正方形的面积为："+shape1.Area());
//        System.out.println("正方形的周长为："+shape1.Perimeter());
    }
}
